#include <iostream>

#include "rclcpp/rclcpp.hpp"
#include "std_msgs/msg/int32.hpp"

class SubscriptionNode : public rclcpp::Node {
public:
  SubscriptionNode(std::string name) : Node(name) {
    subscription_ = this->create_subscription<std_msgs::msg::Int32>(
        "topic_queue", 10,
        std::bind(&SubscriptionNode::_topic_callback, this,
                  std::placeholders::_1));
  }

private:
  void _topic_callback(const std_msgs::msg::Int32::SharedPtr msg) {
    RCLCPP_INFO(this->get_logger(), "Subscription heard: %d", msg->data);
  }
  rclcpp::Subscription<std_msgs::msg::Int32>::SharedPtr subscription_{};
};

int main(int argc, char **argv) {
  rclcpp::init(argc, argv);
  auto node = std::make_shared<SubscriptionNode>("subscription_01");
  rclcpp::spin(node);
  rclcpp::shutdown();

  return 0;
}